#ifndef _definition_h_
#include "lib.h"
#define _definition_h_
#endif


/*
 * CONSTANTS
 */

data_t data_in;
int S = 10; //the number of sample train or test

int processEvent() {

	/*if (readFile(data) == -1) {
		cout << "Error reading input file!!!" << endl;
		return 0;
	}*/
	/* *******************************************
	data = get_xyz_data()
	**********************************************
	*/

    data_in.data_x = readFile( &(data_in.num),"left_x.txt");
        for (int i=0;i<R;i++){
            for (int j=0;j<data_in.num;j++){
                cout << data_in.data_x[i][j]<<" ";
            }
            cout <<endl;
        }
	data_in.data_y=readFile(&(data_in.num),"left_y.txt");
	for (int i=0;i<R;i++){
        for (int j=0;j<data_in.num;j++){
            cout << data_in.data_y[i][j]<<" ";
        }
        cout <<endl;
	}
    data_in.data_z=readFile(&(data_in.num),"left_z.txt");
	for (int i=0;i<R;i++){
        for (int j=0;j<data_in.num;j++){
            cout << data_in.data_z[i][j]<<" ";
        }
        cout <<endl;
	}
	data_t data_max,data_min,data_diff;
	data_min.data_x = min_data(data_in.data_x,data_in.num);
	for (int j=0;j<9;j++){
        cout<<data_min.data_x[0][j]<<" ";
	}
	cout <<endl;
    data_max.data_x = max_data(data_in.data_x,data_in.num);
	for (int j=0;j<9;j++){
        cout<<data_max.data_x[0][j]<<" ";
	}
	cout <<endl;
	data_diff.data_x=sub_matrix(data_max.data_x,data_min.data_x,1,data_in.num);
		for (int j=0;j<data_in.num;j++){
        cout<<data_diff.data_x[0][j]<<" ";
	}
	cout <<endl;
	cout <<endl;
	double** mean,**centroids,**Train,**P;
	centroids = get_point_centroids(data_in,N,D);

	for (int i=0;i<N;i++){
        for (int j=0;j<D;j++){
            cout << centroids[i][j]<<" ";
        }
        cout <<endl;
	}
	cout <<endl;
	Train = get_point_clusters(data_in,centroids,D);
	cout<<"train"<<endl;
	for (int i=0;i<data_in.num;i++){
        for (int j=0;j<R;j++){
            cout << Train[i][j]<<" ";
        }
        cout <<endl;
	}
	cout <<endl;
	P=prior_transition_matrix(M,LR);
		for (int i=0;i<M;i++){
        for (int j=0;j<M;j++){
            cout << P[i][j]<<"     ";
        }
        cout <<endl;
	}
	int *bins = new int ();
	int s=0;
	double **E;
	for(int i = 0;i<N;i++){
        bins[i]=s;
        s++;
	}
		E=dhmm_numeric(Train,P,bins,8,50,0.00001);
		for (int i=0;i<s;i++){
        for (int j=0;j<8;j++){
            cout << E[i][j]<<"     ";
        }
        cout <<endl;
	}
	cout<<"so pt "<<N;
// ****************************

	// put your code to initialize heroes and process events here
	return 1;
}
